package com.itheima.iojob1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Test {
    public static void main(String[] args){

        try {
            read1();
            System.out.println("======");
            read2();
        } catch (IOException e) {
            System.out.println("异常");
        }
    }

    public static void read1() throws IOException {
        FileInputStream fis = new FileInputStream("e:test/file01.txt");//一次读取一个字节
        int read ;
        while ((read=fis.read())!=-1){
            System.out.print((char)read);
        }
        System.out.println();
    }
    public static void read2() throws IOException {
        FileInputStream fis = new FileInputStream("e:test/file01.txt");//一次读取多个字符
        byte[] buf = new byte[3];
        int len;
        while((len=fis.read(buf))!=-1){
            System.out.print(new String(buf,0,len));
        }
    }
}
